Page({
  data:{
      title:'王牌强档',
      cur:0
  },
  onLoad:function(options){
      var that = this;
      wx.request({
        url: 'http://mobile.api.hunantv.com/channel/getWPDetail',
        header:{
            'Content-Type': 'application/json'
        },
        success: function(res){
            that.getProcessData(res.data);
            var picImg = res.data.data[0].picUrl;
            that.setData({bg:picImg});
        }
      });
  },
  getProcessData:function(res){
      var tvArr = [];
      var tvData = res.data;
      for(var i=0;i<tvData.length-2;i++){
          var temp = {
              picImg:tvData[i].picUrl,
              name:tvData[i].name,
              desc:tvData[i].desc
          }
          tvArr.push(temp);
      }
      this.setData({
          tv:tvArr,
          num:tvArr.length+1
      })
  },
  onChangeTap:function(event){
      var cur = event.detail.current;
      var len = this.data.tv.length;
      if(cur==len){
          wx.navigateTo({
            url: '../more/more',
            success:function(){
                this.setData({
                    current:len-1
                })
            }.bind(this)
          })
      }else{
        this.setData({
            bg:this.data.tv[cur].picImg,
            cur:cur
        });
      }
      
  }
})